#include <linux/init.h>
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/errno.h>


#include <linux/timer.h>



void function_test(struct timer_list *);

// 定义一个定时器
DEFINE_TIMER(timer_test, function_test);

void function_test(struct timer_list *timer)
{
    printk(KERN_EMERG "timer over!\n");
    mod_timer(timer, jiffies_64 + msecs_to_jiffies(3000));
}



static int __init timer_test_init(void)
{
    //注册定时器之前，需要设置定时时间
    timer_test.expires = jiffies_64 + msecs_to_jiffies(3000);
    add_timer(&timer_test);

    return 0;

}

static void __exit timer_test_exit(void)
{
    del_timer(&timer_test);
    printk(KERN_EMERG "moule_exit\n");
}

module_init(timer_test_init);
module_exit(timer_test_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("treasure1029");
